<template>
    <sky-base-page>
        <up-swiper :list="swiperData" height="240"></up-swiper>
        <sky-goods-card>
            <sky-goods :dataList="goodsList"/>
        </sky-goods-card>
    </sky-base-page>
</template>
<script setup>

const swiperList = ref([]);
const goodsList = ref([]);
const swiperData=computed(()=>{
    return swiperList.value.map(item=>item.url)
})
// 获取轮播图
const getSwiper = async () => {
    const res = await qly.api.user.swiper.getSwiper({type:1})
    if (res.code === 1) {
        swiperList.value = res.data
    } else {
        qly.dialog.apiError(res).catch()
    }
}
// 获取轮播图
const getGoodsList = async () => {
    const data={
        page:1,
        page_size:20
    }
    const res = await qly.api.user.goods.index(data)
    if (res.code === 1) {
        goodsList.value = res.data.data
    } else {
        qly.dialog.apiError(res).catch()
    }
}
onLoad(() => {
    getSwiper() // 获取轮播图
    getGoodsList() // 获取商品列表
})
</script>
<style scoped>

</style>
